package edu.zut.dao.impl;

import edu.zut.dao.UserDao;
import edu.zut.util.DBUtils;

import java.sql.ResultSet;
import java.sql.SQLException;

public class UserDaoImpl implements UserDao {

    /**
     * 用户登录认证查询操作
     * @param name
     * @param psw
     * @return
     */
    @Override
    public boolean userQueryByNameAndPsw(String name, String psw) {

        String sql = "select * from user where username=? and password=?";
        ResultSet rs = DBUtils.query(sql, name, psw);
        try {
            if (rs.next()){
                return true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }
}
